﻿using AutoMapper;
using Common.Communal;
using ERP.Domain.Scheduling;
using MediatR;
using Scheduling.Api.Write.Application.Command.TeamTypeCommand;
using Scheduling.Services.TeamTypes;

namespace Scheduling.Api.Write.Application.CommandHandlers.TeamTypeHandler
{
    public class TeamTypeUpdCommandHandler : IRequestHandler<TeamTypeUpdCommand, ApiResult<int>>
    {
        public TeamTypeUpdCommandHandler(ITeamTypeServices teamType,IMapper mapper)
        {
            TeamType = teamType;
            Mapper = mapper;
        }

        public ITeamTypeServices TeamType { get; }
        public IMapper Mapper { get; }

        public Task<ApiResult<int>> Handle(TeamTypeUpdCommand request, CancellationToken cancellationToken)
        {
            var list = Mapper.Map<TeamType>(request);
            return TeamType.UpdTeamType(list);
        }
    }
}
